package com.mkvld.appietijdenv2.cloud;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;

public class GcmReceiver extends WakefulBroadcastReceiver {
	
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.v(CloudV9.TAG, "Cloud message receiverd");
		/*Intent i = new Intent(context, SyncServiceV9.class);
		String messageType = intent.getStringExtra("type");
		if (messageType.equals("sync_prefs")) {
			//i.setAction(SyncServiceV9.SYNC_TYPE_PREFS);
		} else if (messageType.equals("sync_shifts")) {
			i.setAction(SyncServiceV9.SYNC_TYPE_SHIFTS);
			i.putExtra("year", intent.getIntExtra("year", 2013));
			i.putExtra("week", intent.getIntExtra("week", 0));
		}
		context.startService(i);*/
		
		// Explicitly specify that GcmIntentService will handle the intent.
        ComponentName comp = new ComponentName(context.getPackageName(),
        		SyncServiceV9.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
	}
}
